from openai import OpenAI
from app import config

def get_llm_client():
    """
    Initializes and returns a reusable OpenAI client based on the application's configuration.
    
    This function allows for compatibility with various OpenAI-compatible services
    by using the base_url and api_key from the central configuration.
    
    :return: An instance of the OpenAI client.
    """
    return OpenAI(
        api_key=config.OPENAI_API_KEY,
        base_url=config.OPENAI_API_BASE_URL
    )

# Initialize a global client instance to be reused across the application
# This avoids re-creating the client for every request.
client = get_llm_client()
